package com.bluecoffee.service;

import com.bluecoffee.domain.Book;
import com.bluecoffee.repository.BookDao;
import com.bluecoffee.rest.ResultJson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * Created by qianlong on 2016/12/19.
 */
@Service
public class BookService {

    @Autowired
    private BookDao bookDao;

    public ResultJson addBook(Book book){
        ResultJson result = new ResultJson();
        book.setBookId(System.currentTimeMillis());
        book.setCreateTime(new Date());
        bookDao.insertBook(book);
        result.setIsSuccess(true);
        result.setErrorCode("0000");
        result.setResultDesc("创建书籍成功");
        return result;
    }

    public List<Book> listBook(Book queryCond){
        return bookDao.listBook(queryCond);
    }

}
